home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re What Kind of File do I Have < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  2.5 KB  |  [TEXT/ttxt]

  1. Subject:     Re: What Kind of File do I Have?
  2. Sent:        6/27/96 4:54 PM
  3. Received:    6/27/96 5:01 PM
  4. From:        David McCusker, david_mccusker@powertalk.apple.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. Ken Boyer (kboyer@itsnet.com) writes: 
  9. > I have a FW_PFileSpecification, is there a way to determine if a file has
  10. > a valid bento storage unit associated with it?
  11.  
  12. I don't know FW_PFileSpecification (or any classes in ODF), but if you can
  13. read any bytes from a file given such a spec, I can tell you how to
  14. determine whether it appears to be a Bento file (see below).
  15.  
  16. While an OpenDoc Bento file is a container with a draft inside, it's not
  17. clear what you mean by having bento storage unit associated with it.
  18.  
  19. > I have tried using FW_AcquireFileContainer, but it throws an exception
  20. > inside OpenDoc and causes my part to quit. I would like to open WordPerfect
  21. > & Word files, and extract data from them.
  22.  
  23. There do not appear to be any utility functions that answer questions
  24. like "is this a Bento file?" or "is this an OpenDoc file?" Typically
  25. OpenDoc tries to open a file using Bento and understands that failure
  26. probably means the file was not a Bento file.  (You should interpret
  27. an exception thrown in such a context as meaning "this is not an OpenDoc
  28. file.")
  29.  
  30. There will probably be a utility function like this in a few months,
  31. so you might write your own and substitute the standard one when it
  32. appears (or implement your utility using the standard function).
  33.  
  34. Currently the last 24 bytes of a file contains the Bento label.  The
  35. first 8 bytes of the label should be the following 8 byte string:
  36.  
  37. "\xA4" "CM" "\xA5" "Hdr" "\xD7"
  38.  
  39. or represented completely in hex:
  40.  
  41. A4 43 4D A5  48 64 72 D7   // . C M . H d r .
  42.  
  43. Note that while this is always true of OpenDoc files today, this might not
  44. always be true of OpenDoc files in the future.  So you must abstract.
  45.  
  46. Because this information is a private implementation detail, if you depend
  47. on this identification of OpenDoc files, you will break in the future.  If
  48. we already had API to do this, we could prevent you from breaking.
  49.  
  50. Breaking is bad, so to be robust you should only treat this as a heuristic
  51. that is backed up by alternative means of dealing with OpenDoc files.
  52. Your part is allowed to behave better when this label is found, but not
  53. badly when it is not found.
  54.  
  55. David McCusker, OpenDoc Storage & Bento, david_mccusker@powertalk.apple.com
  56.  
  57.